import React from 'react';
import Icon from './Icon';
import FileButton from './FileButton';
import { noop } from '../utils';

/**
 * 删除按钮
 * @param {any} props 
 */
export default function FileButtonRemove(props) {
    const {
        listType,
        file,
        ifShowRemove,
        children,
        onRemove = noop,
        ...otherProps
    } = props;

    if (!ifShowRemove) {
        return null;
    }
    
    return (
        <FileButton
            listType={listType}
            file={file}
            name="remove"
            onClick={e => {
                onRemove(file, e);
            }}
            {...otherProps}
        >
            {children || <Icon type="trash" />}
        </FileButton>
    );
}